package com.wc.alorithm_luogu.P1464;

import java.util.Scanner;

/**
 * @Author congge
 * @Date 2023/7/21 18:32
 * @description Function
 * https://www.luogu.com.cn/problem/P1464
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        Main main = new Main();
        long a = 0;
        long b = 0;
        long c = 0;
        while (true) {
            a = sc.nextLong();
            b = sc.nextLong();
            c = sc.nextLong();
            if (a == -1 && b == -1 && c == -1)
                break;
            long ans = main.function(a, b, c);
            main.print(a, b, c, ans);
        }
    }


    long[][][] map = new long[21][21][21];

    public long function(long aa, long bb, long cc) {
        if (aa <= 0 || bb <= 0 || cc <= 0) {
            return 1L;
        } else if (aa > 20 || bb > 20 || cc > 20) {
            return function(20, 20, 20);
        }
        int a = (int) aa;
        int b = (int) bb;
        int c = (int) cc;
        if (a < b && b < c) {

            if (map[a][b][c - 1] == 0) {
                map[a][b][c - 1] = function(a, b, c - 1);
            }
            if (map[a][b - 1][c - 1] == 0) {
                map[a][b - 1][c - 1] = function(a, b - 1, c - 1);
            }
            if (map[a][b - 1][c] == 0) {
                map[a][b - 1][c] = function(a, b - 1, c);
            }
            map[a][b][c] = map[a][b][c - 1] + map[a][b - 1][c - 1] - map[a][b - 1][c];
        } else {
            if (map[a - 1][b][c] == 0) {
                map[a - 1][b][c] = function(a - 1, b, c);
            }
            if (map[a - 1][b - 1][c] == 0) {
                map[a - 1][b - 1][c] = function(a - 1, b - 1, c);
            }
            if (map[a - 1][b][c - 1] == 0) {
                map[a - 1][b][c - 1] = function(a - 1, b, c - 1);
            }
            if (map[a - 1][b - 1][c - 1] == 0) {
                map[a - 1][b - 1][c - 1] = function(a - 1, b - 1, c - 1);
            }
            map[a][b][c] = map[a - 1][b][c] + map[a - 1][b - 1][c] + map[a - 1][b][c - 1] - map[a - 1][b - 1][c - 1];
        }


        return map[a][b][c];
    }

    public void print(long a, long b, long c, long ans) {
        StringBuffer str = new StringBuffer();
        str.append("w(");
        str.append(a);
        str.append(", ");
        str.append(b);
        str.append(", ");
        str.append(c);
        str.append(") ");
        str.append("= ");
        str.append(ans);
        System.out.println(str);
    }
}

